package com.scott.ch020;

import redis.clients.jedis.Jedis;

import java.util.Set;

/**
 * @author 黄后林
 * @version 1.0
 * @note
 * @date 2022-03-25 10:34:57
 */
public class Key {

    public static void main(String[] args) throws Exception {
        Jedis jedis = new Jedis("192.168.88.129", 6379);

        //Redis String  添加
        jedis.set("phone","13267128038");


        String phone = jedis.get("phone");
        System.out.println("phone="+phone);

        Long ttl1 = jedis.ttl("phone");
        System.out.println("ttl="+ttl1);

        jedis.expire("phone",20);

        Thread.sleep(2000);
        Long ttl2= jedis.ttl("phone");
        System.out.println("ttl="+ttl2);

        Boolean exists = jedis.exists("phone");
        System.out.println("exists="+exists);

        Set<String> keys = jedis.keys("*");
        System.out.println(keys);
    }
}
